import React, { PureComponent, Fragment } from 'react';
import { connect } from 'dva';
import { Link } from 'dva/router';
import {
  Table,
  Card,
} from 'antd';

import PageHeaderLayout from '../../../layouts/PageHeaderLayout';

@connect(({ risk, apply }) => ({
  risk,
  apply,
}))
export default class BusinessSupplementList extends PureComponent {
  componentDidMount() {
    const { dispatch } = this.props;
    dispatch({
      type: 'risk/getTaskList',
      payload: {
        offset: 0,
        limit: 10,
        taskState: 1,
        taskCode: 'buchong',
      },
    });
  }

  tableColumns = [
    { title: '业务编号', dataIndex: 'bizNum', key: 'bizNum' },
    { title: '客户姓名', dataIndex: 'custName', key: 'custName' },
    { title: '创建时间', dataIndex: 'createTime', key: 'createTime' },
    {
      title: '操作',
      render: (text, reacd) => (
        <Fragment>
          <Link to={`/apply/fillApply?id=${reacd.id}&taskId=${reacd.taskId}&applyDisabled=${2}`}>
            处理
          </Link>
        </Fragment>
      ),
    },
  ];

  // tableColumns = [
  //   { title: '业务编号', dataIndex: 'bizNum', key: 'bizNum' },
  //   { title: '客户姓名', dataIndex: 'custName', key: 'custName' },
  //   { title: '产品名称', dataIndex: 'productName', key: 'productName' },
  //   { title: '状态', dataIndex: 'state', key: 'state' },
  //   {
  //     title: '征信筛查',
  //     dataIndex: 'creditState',
  //     key: 'creditState',
  //   },
  //   { title: '创建时间', dataIndex: 'createTime', key: 'createTime' },
  //   {
  //     title: '操作',
  //     render: (text, reacd) => (
  //       <Fragment>
  //         <Link to={`/apply/fillApply?id=${reacd.id}&taskId=${reacd.taskId}&applyDisabled=${2}`}>
  //           详情
  //         </Link>
  //       </Fragment>
  //     ),
  //   },
  // ];

  handleStandardTableChange = e => {
    this.props.dispatch({
      type: 'risk/getTaskList',
      payload: {
        offset: (e.current - 1) * e.pageSize,
        limit: e.pageSize,
        taskState: 1,
        taskCode: 'buchong',
      },
    });
  };

  render() {
    const { apply: { applyList, applyLoading, applyPage } } = this.props;
    const { risk: { riskTaskList, riskLoading, riskPage } } = this.props;

    return (
      <PageHeaderLayout title="申请资料">
        <Card>
          {/* {JSON.stringify(riskTaskList)} */}
          <Table
            pagination={riskPage}
            loading={riskLoading}
            rowKey="id"
            dataSource={riskTaskList}
            columns={this.tableColumns}
            onChange={this.handleStandardTableChange}
          />
        </Card>
      </PageHeaderLayout>
    );
  }
}
